package com.anolesoft.yr.mbus.code.controller;

import com.anolesoft.yr.mbus.code.service.CodeIncrementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhj
 * @date 2020/9/18 14:42
 */
@RestController
public class CodeGenController {
    @Autowired
    public RedisTemplate redisTemplate;

    @Autowired
    private CodeIncrementService codeIncrementService;
    @GetMapping("/api/code/test")
    public Integer getCode(){
        Integer i = redisTemplate.opsForValue().increment("mycode").intValue();
        System.out.println(i);
        return i;
    }


    @GetMapping("/api/code/test2")
    public String getCode2(){
        String bb = codeIncrementService.getValue("bb");
        return bb;
    }
}
